home *** CD-ROM | disk | FTP | other *** search
- unit Ropwin;
-
- { This is the window class don't install it. install Troppop.pas
- TRopPop 1.0 (c) 1995 by Eyal Frank
- Tel Aviv
- Israel
- CIS : 100274,3376
- EMail frank-e@Trendline.co.il
-
- This is my first component , i realy want to get any feedback,
- So drop me an Email please.
- }
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, ExtCtrls;
-
- type
- TRopInst = class(TForm)
- Timer1: TTimer;
- procedure FormPaint(Sender: TObject);
- procedure FormKeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure FormCreate(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Timer1Timer(Sender: TObject);
- private
- procedure WMEraseBkng(var MSg:TWMEraseBkgnd);message WM_ERASEBKGND;
- protected
- procedure CreateParams(var Params: TCreateParams);override;
- public
- sText:TStringList;
- formBrush:TBrush;
- xPos,yPos:Integer;
- timerClose:Integer;
- procedure DoInit;
-
- end;
-
- const
- SD_WIDTH = 16;
- SD_HEIGHT = 16;
- SD_OFFSET = 16;
- var
- RopInst: TRopInst;
-
- implementation
-
- {$R *.DFM}
-
- procedure TRopInst.CreateParams(var Params: TCreateParams);
- begin
- inherited CreateParams(Params); { call the inherited first }
- with Params do
- begin
- Style := Style or WS_POPUP;
- Style := Style and not (WS_CAPTION or WS_CHILD);
- WindowClass.hbrBackground:=GetStockObject(NULL_BRUSH);
- WindowClass.Style:= WindowClass.Style or CS_SAVEBITS;
- end;
- end;
- procedure TRopInst.WMEraseBkng(var MSg:TWMEraseBkgnd);
- begin
- Msg.Result:=1;
- end;
- procedure TRopInst.FormPaint(Sender: TObject);
- const
- bmBits: Array[0..7] of Integer=($AA,$55,$AA,$55,$AA,$55,$AA,$55);
- var
- rect,rc:TRect;
- szText:PChar;
- bm:HBITMAP;
- hbr,hold:HBRUSH;
- begin
- {if csDesigning in ComponentState then
- exit;}
- bm:=CreateBitmap(8, 8, 1, 1, @bmBits[0]);
- szText:=sText.GetText;
- Canvas.Rectangle(1 ,
- 1,
- ClientWidth - SD_WIDTH,
- ClientHeight - SD_HEIGHT);
- Canvas.Brush:=formBrush;
- Canvas.Rectangle(1 ,
- 1,
- ClientWidth - SD_WIDTH,
- ClientHeight - SD_HEIGHT);
- SetBkMode(Canvas.Handle,TRANSPARENT);
-
- rc:=ClientRect;
- {// Write some text to this window}
- rect.left := rc.left + 1 + 5;
- rect.top := rc.top + 1 + 5;
- rect.right := rc.right - SD_WIDTH - 5;
- rect.bottom := rc.bottom - SD_HEIGHT - 5;
- DrawText(Canvas.Handle, szText, -1, rect, DT_LEFT);
-
- hbr := CreatePatternBrush(bm);
- hOld := SelectObject(Canvas.Handle, hbr);
- PatBlt(Canvas.Handle,
- rc.left + SD_OFFSET,
- rc.bottom - SD_HEIGHT,
- rc.right - SD_OFFSET,
- SD_HEIGHT,
- $A000C9);
-
- { right-side shadow}
-
- PatBlt(Canvas.Handle,
- rc.right - SD_WIDTH,
- rc.top + SD_OFFSET,
- SD_WIDTH,
- rc.bottom,
- $A000C9);
- SelectObject(Canvas.Handle, hOld);
- DeleteObject(hbr);
- DeleteObject(bm);
-
- end;
-
- procedure TRopInst.FormKeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- Close;
- end;
-
- procedure TRopInst.DoInit;
- var
- cx,cy,len,ret,x,y:Integer;
- rc: TRect;
- szText:PChar;
- begin
- if csDesigning in ComponentState then
- exit;
- SetCapture(Handle);
- cy:=GetSystemMetrics(SM_CYSCREEN);
- cx:=GetSystemMetrics(SM_CXSCREEN);
- {sText.Add('XPos: '+IntToStr(XPos));
- sText.Add('YPos: '+IntToStr(YPos));}
- szText:=sText.GetText;
- Canvas.Font:=Font;
- Canvas.Pen.Width:=2;
- ret:=DrawText(Canvas.Handle,szText,-1,rc,DT_LEFT or DT_CALCRECT);
- if XPos=0 then
- x:= (cx-(rc.right-rc.left)) div 2
- else
- x:=XPos;
- if YPos=0 then
- y:= (cy-(rc.bottom-rc.top)) div 2
- else
- y:=YPos;
- SetBounds(x,y,rc.right-rc.left+40,
- rc.bottom-rc.top+30);
- if timerClose > 0 then
- begin
- Timer1.Interval:=timerClose;
- Timer1.Enabled:=true;
- end;
- end;
-
- procedure TRopInst.FormCreate(Sender: TObject);
- begin
- sText:=TStringList.Create;
- formBrush:=TBrush.Create;
- XPos:=0;
- YPos:=0;
- timerClose:=0;
- end;
-
- procedure TRopInst.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- sText.Free;
- formBrush.Free;
- ReleaseCapture;
- end;
-
- procedure TRopInst.FormMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- Close;
- end;
-
- procedure TRopInst.Timer1Timer(Sender: TObject);
- begin
- Close;
- end;
-
- end.
-